//计算点击总数（pv）、收藏总数（fav）、加入购物车总数（cart）、购买总数（buy）

package com.neuedu.hadoop.taobao.Step02.Reducer;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
import java.io.IOException;

public class UserBehaviorReducer extends Reducer<Text, LongWritable, Text, LongWritable> {
    private final LongWritable outValue = new LongWritable();
    @Override
    protected void reduce(Text key, Iterable<LongWritable> values,
                          Reducer<Text, LongWritable, Text, LongWritable>.Context context)
            throws IOException, InterruptedException {
        long cnt = 0;
        for (LongWritable value : values) {
            cnt++;
        }
        outValue.set(cnt);
        context.write(key, outValue);
    }
}